package com.erp.entity.sale;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.erp.entity.goods.MultipleUnit;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

public class SaleOrderDetail {
    private Integer id;
    private String linkSaleOrderNumber;

    private Integer goodsId;

    private Integer goodsNum;



    private Integer sellwareHouseId;

    private Integer basicNum;

    private BigDecimal salePrice;
    private String linkSaleNumber;

    private Date deliveryDate;

    private Integer isGift;

    private BigDecimal taxRate;

    private BigDecimal salePriceTax;

    private BigDecimal taxPrice;

    private BigDecimal goodsDiscountRate;

    private BigDecimal goodsDiscountAmount;

    private BigDecimal amountAfGoodsDis;

    private BigDecimal goodsTotalPrice;

    private BigDecimal priceAndTax;
    private BigDecimal salePriceTaxDis;

    private BigDecimal refCost;

    private BigDecimal eGrossProfit;

    private BigDecimal eGrossProfitPc;

    private BigDecimal recentCost;

    private Integer companyId;
    private Integer purchasedNum;//商品被采购的数量
    private String goodsRemarks;
    private Integer basicUnitId;//基本单位ID
    private Integer multipleUnitId;//多单位ID
    //----------冗余字段-------
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date receiptDate;//生成销货单时，根据商品查询销货订单明细时表格中要展示的字段
    private String goodsName;//商品名称
    private String goodsImage;//商品图片
    private String goodsAttribute;//商品属性
    private String goodsBrand;//商品品牌
    private String goodsCode;//商品编号

    private String basicUnitName;//基本单位名称

    private String multipleUnitName;//多单位名称
    private String sellwareHouseName;//出库仓库名称
    private List<MultipleUnit> multipleUnitList;
    public SaleOrderDetail(){}

    public SaleOrderDetail(BigDecimal salePrice){//用来生产销货订单的构造方法，初始化数据
        setPurchasedNum(0);
        //设置商品数量初始参数
        setBasicNum(1);
        setGoodsNum(1);
        this.salePrice = salePrice;
        //设置税率相关初始参数
        setTaxRate(BigDecimal.ZERO);//税率
        setTaxPrice(BigDecimal.ZERO);//税额
        setSalePriceTax(salePrice);//含税单价
        setSalePriceTaxDis(salePrice);//折后含税单价

        //设置价税合计
        setPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(getGoodsNum())));//价税合计

        //设置折扣率相关初始参数
        setGoodsDiscountRate(BigDecimal.ZERO);//折扣率
        setGoodsDiscountAmount(BigDecimal.ZERO);//折扣额
        setAmountAfGoodsDis(salePrice);
        //设置商品的折后金额
        setGoodsTotalPrice(getAmountAfGoodsDis().multiply(BigDecimal.valueOf(getBasicNum())));

    }
    //用于修改或添加的有参构造
    public SaleOrderDetail(BigDecimal salePrice,BigDecimal taxRate,
                           BigDecimal discountRate,Integer goodsNum,
                           Integer basicNum){
        setPurchasedNum(0);
        setGoodsNum(goodsNum);
        setBasicNum(basicNum);
        setSalePrice(salePrice);
        //设置税率相关信息
        setTaxRate(taxRate);
        setTaxPrice(BigDecimal.valueOf(getBasicNum()).multiply(salePrice).multiply(getTaxRate().multiply(BigDecimal.valueOf(0.01))));//计算税额
        setSalePriceTax(salePrice.add(salePrice.multiply(taxRate.multiply(BigDecimal.valueOf(0.01)))));//设置含税单价

        //设置折扣相关信息
        setGoodsDiscountRate(discountRate);//设置商品折扣率
        setGoodsDiscountAmount(BigDecimal.valueOf(basicNum)
                                .multiply(discountRate.multiply(BigDecimal.valueOf(0.01)))
                                .multiply(salePrice));//设置商品折扣额
        setAmountAfGoodsDis(discountRate.multiply(salePrice).multiply(BigDecimal. valueOf(0.01)).add(salePrice)); //设置商品折后单价
        setGoodsTotalPrice(getAmountAfGoodsDis().multiply(BigDecimal.valueOf(getBasicNum())));//设置商品折后金额
        setSalePriceTaxDis(getAmountAfGoodsDis().add(salePrice.multiply(getTaxRate().multiply(BigDecimal.valueOf(0.01)))));//设置商品折后含税单价
        //设置商品价税合计
        setPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(basicNum)));
    }
    public void setBasicInfo(BigDecimal salePrice){//单单位商品初始化信息
        setPurchasedNum(0);
        //设置商品数量初始参数
        setBasicNum(1);
        setGoodsNum(1);
        this.salePrice = salePrice;
        //设置税率相关初始参数
        setTaxRate(BigDecimal.ZERO);//税率
        setTaxPrice(BigDecimal.ZERO);//税额
        setSalePriceTax(salePrice);//含税单价
        setSalePriceTaxDis(salePrice);//折后含税单价

        //设置价税合计
        setPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(getGoodsNum())));//价税合计

        //设置折扣率相关初始参数
        setGoodsDiscountRate(BigDecimal.ZERO);//折扣率
        setGoodsDiscountAmount(BigDecimal.ZERO);//折扣额
        setAmountAfGoodsDis(salePrice);
        //设置商品的折后金额
        setGoodsTotalPrice(getAmountAfGoodsDis().multiply(BigDecimal.valueOf(getBasicNum())));
    }
    public void setBasicInfo(BigDecimal salePrice,Integer goodsNum,Integer basicNum){//多单位商品初始化信息
        setPurchasedNum(0);
        //设置商品数量初始参数
        setBasicNum(basicNum);
        setGoodsNum(goodsNum);
        this.salePrice = salePrice;
        //设置税率相关初始参数
        setTaxRate(BigDecimal.ZERO);//税率
        setTaxPrice(BigDecimal.ZERO);//税额
        setSalePriceTax(salePrice);//含税单价
        setSalePriceTaxDis(salePrice);//折后含税单价

        //设置价税合计
        setPriceAndTax(getSalePriceTaxDis().multiply(BigDecimal.valueOf(getGoodsNum())));//价税合计

        //设置折扣率相关初始参数
        setGoodsDiscountRate(BigDecimal.ZERO);//折扣率
        setGoodsDiscountAmount(BigDecimal.ZERO);//折扣额
        setAmountAfGoodsDis(salePrice);
        //设置商品的折后金额
        setGoodsTotalPrice(getAmountAfGoodsDis().multiply(BigDecimal.valueOf(getBasicNum())));
    }

    public String getLinkSaleNumber() {
        return linkSaleNumber;
    }

    public void setLinkSaleNumber(String linkSaleNumber) {
        this.linkSaleNumber = linkSaleNumber;
    }

    public List<MultipleUnit> getMultipleUnitList() {
        return multipleUnitList;
    }

    public void setMultipleUnitList(List<MultipleUnit> multipleUnitList) {
        this.multipleUnitList = multipleUnitList;
    }

    public Integer getPurchasedNum() {
        return purchasedNum;
    }

    public void setPurchasedNum(Integer purchasedNum) {
        this.purchasedNum = purchasedNum;
    }

    public String getGoodsCode() {
        return goodsCode;
    }

    public void setGoodsCode(String goodsCode) {
        this.goodsCode = goodsCode;
    }

    public Date getReceiptDate() {
        return receiptDate;
    }

    public void setReceiptDate(Date receiptDate) {
        this.receiptDate = receiptDate;
    }

    public BigDecimal getSalePriceTaxDis() {
        return salePriceTaxDis;
    }

    public void setSalePriceTaxDis(BigDecimal salePriceTaxDis) {
        this.salePriceTaxDis = salePriceTaxDis;
    }


    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsImage() {
        return goodsImage;
    }

    public void setGoodsImage(String goodsImage) {
        this.goodsImage = goodsImage;
    }

    public String getGoodsAttribute() {
        return goodsAttribute;
    }

    public void setGoodsAttribute(String goodsAttribute) {
        this.goodsAttribute = goodsAttribute;
    }

    public String getGoodsBrand() {
        return goodsBrand;
    }

    public void setGoodsBrand(String goodsBrand) {
        this.goodsBrand = goodsBrand;
    }

    public Integer getBasicUnitId() {
        return basicUnitId;
    }

    public void setBasicUnitId(Integer basicUnitId) {
        this.basicUnitId = basicUnitId;
    }

    public String getBasicUnitName() {
        return basicUnitName;
    }

    public void setBasicUnitName(String basicUnitName) {
        this.basicUnitName = basicUnitName;
    }

    public Integer getMultipleUnitId() {
        return multipleUnitId;
    }

    public void setMultipleUnitId(Integer multipleUnitId) {
        this.multipleUnitId = multipleUnitId;
    }

    public String getMultipleUnitName() {
        return multipleUnitName;
    }

    public void setMultipleUnitName(String multipleUnitName) {
        this.multipleUnitName = multipleUnitName;
    }

    public String getSellwareHouseName() {
        return sellwareHouseName;
    }

    public void setSellwareHouseName(String sellwareHouseName) {
        this.sellwareHouseName = sellwareHouseName;
    }



    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getLinkSaleOrderNumber() {
        return linkSaleOrderNumber;
    }

    public void setLinkSaleOrderNumber(String linkSaleOrderNumber) {
        this.linkSaleOrderNumber = linkSaleOrderNumber == null ? null : linkSaleOrderNumber.trim();
    }

    public BigDecimal getPriceAndTax() {
        return priceAndTax;
    }

    public void setPriceAndTax(BigDecimal priceAndTax) {
        this.priceAndTax = priceAndTax;
    }

    public Integer getSellwareHouseId() {
        return sellwareHouseId;
    }

    public void setSellwareHouseId(Integer sellwareHouseId) {
        this.sellwareHouseId = sellwareHouseId;
    }

    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public Integer getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(Integer goodsNum) {
        this.goodsNum = goodsNum;
    }



    public Integer getBasicNum() {
        return basicNum;
    }

    public void setBasicNum(Integer basicNum) {
        this.basicNum = basicNum;
    }

    public BigDecimal getSalePrice() {
        return salePrice;
    }

    public void setSalePrice(BigDecimal salePrice) {
        this.salePrice = salePrice;
    }

    public Date getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(Date deliveryDate) {
        this.deliveryDate = deliveryDate;
    }


    public Integer getIsGift() {
        return isGift;
    }

    public void setIsGift(Integer isGift) {
        this.isGift = isGift;
    }

    public BigDecimal getTaxRate() {
        return taxRate;
    }

    public void setTaxRate(BigDecimal taxRate) {
        this.taxRate = taxRate;
    }

    public BigDecimal getSalePriceTax() {
        return salePriceTax;
    }

    public void setSalePriceTax(BigDecimal salePriceTax) {
        this.salePriceTax = salePriceTax;
    }

    public BigDecimal getTaxPrice() {
        return taxPrice;
    }

    public void setTaxPrice(BigDecimal taxPrice) {
        this.taxPrice = taxPrice;
    }

    public BigDecimal getGoodsDiscountRate() {
        return goodsDiscountRate;
    }

    public void setGoodsDiscountRate(BigDecimal goodsDiscountRate) {
        this.goodsDiscountRate = goodsDiscountRate;
    }

    public BigDecimal getGoodsDiscountAmount() {
        return goodsDiscountAmount;
    }

    public void setGoodsDiscountAmount(BigDecimal goodsDiscountAmount) {
        this.goodsDiscountAmount = goodsDiscountAmount;
    }

    public BigDecimal getAmountAfGoodsDis() {
        return amountAfGoodsDis;
    }

    public void setAmountAfGoodsDis(BigDecimal amountAfGoodsDis) {
        this.amountAfGoodsDis = amountAfGoodsDis;
    }

    public BigDecimal getGoodsTotalPrice() {
        return goodsTotalPrice;
    }

    public void setGoodsTotalPrice(BigDecimal goodsTotalPrice) {
        this.goodsTotalPrice = goodsTotalPrice;
    }



    public BigDecimal getRefCost() {
        return refCost;
    }

    public void setRefCost(BigDecimal refCost) {
        this.refCost = refCost;
    }

    public BigDecimal geteGrossProfit() {
        return eGrossProfit;
    }

    public void seteGrossProfit(BigDecimal eGrossProfit) {
        this.eGrossProfit = eGrossProfit;
    }

    public BigDecimal geteGrossProfitPc() {
        return eGrossProfitPc;
    }

    public void seteGrossProfitPc(BigDecimal eGrossProfitPc) {
        this.eGrossProfitPc = eGrossProfitPc;
    }

    public BigDecimal getRecentCost() {
        return recentCost;
    }

    public void setRecentCost(BigDecimal recentCost) {
        this.recentCost = recentCost;
    }



    public Integer getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Integer companyId) {
        this.companyId = companyId;
    }

    public String getGoodsRemarks() {
        return goodsRemarks;
    }

    public void setGoodsRemarks(String goodsRemarks) {
        this.goodsRemarks = goodsRemarks == null ? null : goodsRemarks.trim();
    }
}